New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

otherwise

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

otherwise

Executes fallback behavior if a function was unsuccessful.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-7.72%
Maintainers
1
Weekly downloads
 
Created
Source

otherwise

Executes fallback behavior if a function was unsuccessful. Intended for use in modules that use option object arguments.

Installation

Requires Node.js 6.0.0 or above.

npm i otherwise

API

The module exports a single function.

Parameters

  1. Optional: Object argument:
    • elseCall (function): If provided, this function will be called with one argument: a function that will invoke the other fallbacks. If the function argument is not called, then elseThrow and elseReturn will not be taken into consideration, and the return value of the elseCall function will be forwarded.
    • elseThrow (Error or string): An error to be thrown. A string will be wrapped in an Error object automatically.
    • elseReturn (any): A value to return if elseThrow is omitted.
  2. Optional: defaultErrorClass (Class): An Error class in which to wrap elseThrow if it is a string.

Return Value

Returns the return value of elseCall (if provided) or returns elseReturn.

Keywords

FAQs

Package last updated on 03 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc